home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 December / Australian PC User - December 2003 (CD2).iso / software / apps / files / dwmx2k4.exe / Disk1 / data1.cab / Configuration_En / Objects / Server / GoToRelated.js < prev    next >
Encoding:
JavaScript  |  2003-09-05  |  4.4 KB  |  163 lines

  1. // Copyright 2003 Macromedia, Inc. All rights reserved.
  2.  
  3. // *************** GLOBALS VARS *****************
  4.  
  5. // ******************* API **********************
  6.  
  7. //--------------------------------------------------------------------
  8. // FUNCTION:
  9. //   objectTag
  10. //
  11. // DESCRIPTION:
  12. //   This object is used as a shim to launch the appropriate 
  13. //   command file for the current server model.  The individual
  14. //   command files are responsible for inserting the code on the
  15. //   page, so this function just returns the empty string.
  16. //
  17. // ARGUMENTS:
  18. //   none
  19. //
  20. // RETURNS:
  21. //   string - empty string to indicate that nothing should be inserted
  22. //--------------------------------------------------------------------
  23.  
  24. function objectTag() 
  25. {
  26.   var dom = dw.getDocumentDOM();
  27.   
  28.   if (dom)
  29.   {
  30.     var serverModel = dom.serverModel.getFolderName();
  31.     
  32.     if (serverModel)
  33.     {    
  34.       var serverBehaviorFile = "";
  35.  
  36.       switch (serverModel)
  37.       {
  38.       case "ASP_VBS":
  39.       case "ASP_JS":
  40.       case "JSP":
  41.         serverBehaviorFile = "Go To Related Page.htm";
  42.         break;
  43.  
  44.       case "ASP.NET_Csharp":
  45.       case "ASP.NET_VB":
  46.       case "ColdFusion":
  47.       case "PHP_MySQL":
  48.         // not supported
  49.         break;
  50.  
  51.       default:
  52.         // We will launch a command with the server model
  53.         // as a prefix, so that live objects can be implemented
  54.         // for third party server models.
  55.  
  56.         serverBehaviorFile = "GoToRelatedPage.htm";        
  57.         break;
  58.       } 
  59.  
  60.       if (serverBehaviorFile && canInsertServerObject(serverBehaviorFile))
  61.       {
  62.         dw.popupServerBehavior(serverBehaviorFile);
  63.       }
  64.     }
  65.     else
  66.     {
  67.       alert(MM.MSG_NeedServerModelForSO);
  68.     }
  69.   }
  70.   
  71.   return "";  
  72. }
  73.  
  74. //--------------------------------------------------------------------
  75. // FUNCTION:
  76. //   getSetupSteps
  77. //
  78. // DESCRIPTION:
  79. //   Returns an array of steps to be displayed in an instructions
  80. //   dialog.  The first element of the array is the text that appears
  81. //   above the list.  The remaining elements are the steps, which will
  82. //   be rendered in a numbered list.
  83. //
  84. //   The steps are each HTML, which may contain JavaScript event
  85. //   handlers.  The event handlers can either be a JavaScript script
  86. //   or an "event:KeyWord" syntax.  If the latter is used, then the
  87. //   handler for KeyWord is implemented internally in the Dreamweaver
  88. //   executable.
  89. //
  90. // ARGUMENTS:
  91. //   none
  92. //
  93. // RETURNS:
  94. //   the array described above
  95. //--------------------------------------------------------------------
  96. function getSetupSteps()
  97. {
  98.   return getSetupStepsForServerObject();
  99. }
  100.  
  101.  
  102.  
  103. //--------------------------------------------------------------------
  104. // FUNCTION:
  105. //   setupStepsCompleted
  106. //
  107. // DESCRIPTION:
  108. //   Returns the number of steps (in the list of steps returned from
  109. //   getSetupSteps) that have already been completed.  This number is
  110. //   used to determine how many steps will have a check mark next to
  111. //   them.
  112. //
  113. // ARGUMENTS:
  114. //   none
  115. //
  116. // RETURNS:
  117. //   An integer - the number of check marks to be displayed, or -1
  118. //   if all steps have been completed.
  119. //--------------------------------------------------------------------
  120. function setupStepsCompleted()
  121. {
  122.   return setupStepsCompletedForServerObject();
  123. }
  124.  
  125.  
  126. // ***************** LOCAL FUNCTIONS  ******************
  127.  
  128. //--------------------------------------------------------------------
  129. // FUNCTION:
  130. //   canInsertServerObject
  131. //
  132. // DESCRIPTION:
  133. //   The function returns true if this object can be inserted in the
  134. //   current document.  This function, and the functions it calls should
  135. //   display the necessary error messages.
  136. //
  137. // ARGUMENTS:
  138. //   serverBehaviorFileName - string - the file name of the command file
  139. //     which implements this object
  140. //
  141. // RETURNS:
  142. //   boolean - true if the dialog should be displayed, or false otherwise
  143. //--------------------------------------------------------------------
  144.  
  145. function canInsertServerObject(sbFileName)
  146. {
  147.   var retVal = true;
  148.  
  149.   var curDom = dw.getDocumentDOM();
  150.   var serverModel = (curDom) ? curDom.serverModel.getFolderName() : "";
  151.   var path = dw.getConfigurationPath() + "/ServerBehaviors/" + serverModel
  152.            + "/" + sbFileName;
  153.            
  154.   if (!dwscripts.fileExists(path))
  155.   {
  156.     var err = dwscripts.sprintf(MM.MSG_NeedserverBehaviorFileForSO, path);
  157.     retVal = false;
  158.     alert(err);
  159.   }
  160.   
  161.   return retVal;
  162. }
  163.